package com.leetcode.algorithm.y22.m06;

/**
 * 62. 不同路径
 * 
 * https://leetcode.cn/problems/unique-paths/
 * 
 * @author jie.deng
 *
 */
class Question0062Solution01 {

	public int uniquePaths(int m, int n) {
		// DP状态定义
		int[][] dp = new int[m][n];

		// 初始化
		for (int i = 0; i < m; i++) {
			dp[i][0] = 1;
		}
		for (int j = 0; j < n; j++) {
			dp[0][j] = 1;
		}

		// 状态转移方程
		for (int i = 1; i < m; i++) {
			for (int j = 1; j < n; j++) {
				dp[i][j] = dp[i - 1][j] + dp[i][j - 1];
			}
		}

		return dp[m - 1][n - 1];
	}

}